from django.contrib.auth.models import AbstractUser
from django.db import models

# Create your models here.


class User(AbstractUser):
    """用户模型类"""
    mobile = models.CharField(max_length=11, unique=True, verbose_name="手机号")
    # avatar = models.ImageField(verbose_name='图片头像',default=None)

    class Meta:
        db_table = 'tb_users'
        verbose_name = '个人中心'
        verbose_name_plural = verbose_name


class Homepage(BaseModel):
    living = models.CharField(max_length=50, verbose_name='居住地', default=None)
    college = models.CharField(max_length=50, verbose_name='毕业院校', default=None)
    profession = models.CharField(max_length=50, verbose_name='专业', default=None)
    company = models.CharField(max_length=50, verbose_name='公司', default=None)
    position = models.CharField(max_length=50, verbose_name='职位', default=None)
    website = models.CharField(max_length=50, verbose_name='个人网址', default=None)
    resume = models.TextField(null=True, blank=True, verbose_name='个人简介')
    nickname = models.CharField(max_length=20, verbose_name='昵称')
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='homepage', verbose_name='用户')


    class Meta:
        db_table = 'tb_homepages'
        verbose_name = '我的主页'
        verbose_name_plural = verbose_name
#
#
class Archives(BaseModel):
    user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='archives', verbose_name='用户')
    true_picture = models.ImageField(max_length=50, verbose_name='真人头像')
    true_name = models.CharField(max_length=20, verbose_name='真人姓名')
    gender = models.CharField(max_length=6, verbose_name='性别')
    birthday = models.CharField(max_length=50, verbose_name='出生日期')
    major = models.CharField(max_length=50, verbose_name='擅长技术')
    # home = models.ForeignKey(Homepage,null=True, on_delete=models.CASCADE, related_name='archive', verbose_name='关联主页')

    class Meta:
        db_table = 'tb_archives'
        verbose_name = '个人档案'
        verbose_name_plural = verbose_name
#
#
class Dyanmic(BaseModel):
    user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='user_dy', verbose_name='用户')
    action = models.CharField(max_length=30, verbose_name='操作')
    time = models.CharField(max_length=30, verbose_name='时间')

    class Meta:
        db_table = 'tb_dyanmics'
        verbose_name = '个人动态'
        verbose_name_plural = verbose_name
#
#


class ExperienceWork(BaseModel):
    texts = models.TextField(blank=True, verbose_name='内容')
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='e_work', verbose_name='用户')
    start_time = models.DateField(null=True, verbose_name='开始时间')
    end_time = models.DateField(null=True, verbose_name='结束时间')
    skill = models.CharField(max_length=60, null=True, verbose_name='技术')
    describe = models.CharField(max_length=120, null=True, verbose_name='描述')


    class Meta:
        db_table = 'tb_experience_work'
        verbose_name = '工作经历'
        verbose_name_plural = verbose_name
#
"""
工作经历还需要添加字段
"""


class ExperienceStudy(BaseModel):
    texts = models.TextField(null=True, blank=True, verbose_name='内容')
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='e_study', verbose_name='用户')
    specialty = models.CharField(null=True, max_length=10, verbose_name='所学专业')
    education = models.CharField(max_length=10, null=True, verbose_name='学历')
    achievement = models.CharField(max_length=20, null=True, verbose_name='成就')
    start_time = models.DateField(null=True, verbose_name='开始时间')
    end_time = models.DateField(null=True, verbose_name='结束时间')
    skills = models.CharField(max_length=60, null=True, verbose_name='相关技术')

    class Meta:
        db_table = 'tb_experience_study'
        verbose_name = '教育经历'
        verbose_name_plural = verbose_name
#
# #
# # class Attention(BaseModel):
# #
# #     pass
# #
# #
# # class AttentionQuestions(BaseModel):
# #     id = models.CharField(max_length=6, verbose_name='')
# #
# #
# # class AttentionLabel(BaseModel):
# #     pass
# #
# #
# # class BrowsingHistory(BaseModel):
# #     pass
# #
# #
#
#     pass
#
#
# class AttentionQuestions(BaseModel):
#     id = models.CharField(max_length=6, verbose_name='')
#
#
# class AttentionLabel(BaseModel):
#     pass
#
#
# class BrowsingHistory(BaseModel):
#     pass
#
#
class AccountSet(BaseModel):
    user_name = models.ForeignKey(User, on_delete=models.CASCADE,related_name='account',  verbose_name='用户名')
    password = models.ForeignKey(User, on_delete=models.CASCADE,  verbose_name='用户密码')

    class Meta:
        db_table = 'tb_accounts'
        verbose_name = '账户设置'
        verbose_name_plural = verbose_name


# class UserCollection(models.Model):
#     """用户收藏"""
#     user = models.ForeignKey(User, on_delete=models.CASCADE,
#                              verbose_name="用户")
#     spit = models.ForeignKey("spit.Spit", on_delete=models.CASCADE,
#                              verbose_name="吐槽")
#
